require("../../../mybehaviors/location/location").length;

var t = getApp();

Page({
    data: {
        language: "",
        collectIndex: 0,
        collectStoreIs: !1,
        collectTabs: [ {
            name: "商品",
            status: 1
        }, {
            name: "商户",
            status: 2
        } ],
        commercialList: [],
        isLoadMore: !0,
        page: 1,
        totalPage: 0,
        goodsData: [],
        dataState: 0,
        showEdit: !1,
        indicatorDots: !0,
        vertical: !1,
        autoplay: !0,
        interval: 4e3,
        duration: 300
    },
    claerData: function() {
        var o = this, a = t.getNetAddresss("favorite/Remove");
        a += "&id=" + e.currentTarget.dataset.id, wx.showModal({
            title: "提示",
            content: "确定要删除么？此操作不可逆！",
            success: function(e) {
                e.confirm && (console.log("用户点击确定"), t._getNetWork({
                    url: a,
                    success: function(t) {
                        var a = t.data;
                        console.log("收货地址列表", a), 1 == a.result ? (o._getData(), wx.showToast({
                            title: a.msg,
                            icon: "success",
                            duration: 2e3,
                            success: function() {},
                            fail: function() {}
                        })) : wx.showToast({
                            title: "数据错误",
                            icon: "success",
                            duration: 2e3,
                            success: function() {},
                            fail: function() {}
                        });
                    },
                    fail: function(t) {}
                }));
            }
        });
    },
    openEdit: function() {
        wx.showToast({
            title: "加载中..",
            icon: "loading",
            duration: 1e3,
            mask: !0
        });
        this.setData({
            showEdit: !0
        });
    },
    closeEdit: function() {
        wx.showToast({
            title: "加载中..",
            icon: "loading",
            duration: 1e3,
            mask: !0
        });
        this.setData({
            showEdit: !1
        });
    },
    delData: function(o) {
        var a = this, e = t.getNetAddresss("member.member-favorite.destroy");
        e += "&goods_id=" + o.currentTarget.dataset.goodsid, wx.showModal({
            title: "提示",
            content: "确定要取消收藏么？此操作不可逆！",
            success: function(o) {
                o.confirm && (console.log("用户点击确定"), t._getNetWork({
                    url: e,
                    success: function(t) {
                        var o = t.data;
                        console.log("_data", o), 1 == o.result ? (a._getData(), wx.showToast({
                            title: o.msg,
                            icon: "success",
                            duration: 2e3,
                            success: function() {},
                            fail: function() {}
                        })) : wx.showToast({
                            title: "数据错误",
                            icon: "success",
                            duration: 2e3,
                            success: function() {},
                            fail: function() {}
                        });
                    },
                    fail: function(t) {}
                }));
            }
        });
    },
    goDetail: function(t) {
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + t.currentTarget.dataset.goodsid
        });
    },
    _getData: function() {
        var o = this, a = t.getNetAddresss("member.member-favorite.index");
        1 == t.globalData.store_alone_temp && (a = t.getNetAddresss("plugin.store-alone-temp.frontend.member.favorite-list")), 
        t._getNetWork({
            url: a,
            data: {
                basic_info: 1
            },
            showToastIn: !1,
            success: function(t) {
                var a, e, s = t.data, n = null === (a = s.basic_info.plugin_setting) || void 0 === a ? void 0 : a.coupon_store;
                (console.log("收藏data", s), 1 == s.result) ? (e = s.data.length > 0 ? 2 : 1, "[object Object]" === Object.prototype.toString.call(n) && (o.setData({
                    collectStoreIs: !0
                }), o.storeCollectList()), o.setData({
                    goodsData: s.data,
                    dataState: e
                })) : wx.showToast({
                    title: "数据错误",
                    icon: "success",
                    duration: 2e3
                });
            },
            fail: function(t) {}
        });
    },
    storeCollectList: function() {
        var o = this, a = t.getNetAddresss("plugin.coupon-store.frontend.collection.storeCollectList");
        t._getNetWork({
            url: a,
            data: {
                basic_info: 1
            },
            showToastIn: !1,
            success: function(t) {
                var a = t.data;
                console.log("收藏data", a), 1 == a.result ? a.basic_info.plugin_setting.coupon_store && o.setData({
                    collectStoreIs: !0,
                    commercialList: a.data.data
                }) : wx.showToast({
                    title: "数据错误",
                    icon: "success",
                    duration: 2e3
                });
            },
            fail: function(t) {}
        });
    },
    getMoreData: function() {
        var o = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.totalPage)) {
            this.data.page = this.data.page + 1;
            var a = t.getNetAddresss("plugin.coupon-store.frontend.collection.storeCollectList"), e = {
                cstore_id: this.data.storeId,
                page: this.data.page,
                kwd: this.data.keyword
            };
            t._getNetWork({
                url: a,
                data: e,
                success: function(t) {
                    var a = t.data, e = a.data.data;
                    e.forEach(function(t) {
                        t.checked = !0;
                    }), 1 == a.result ? (o.data.isLoadMore = !0, o.setData({
                        verifierList: o.data.verifierList.concat(e)
                    })) : (o.data.page = o.data.page - 1, o.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    commercialTo: function(t) {
        console.log(t);
        var o = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "../../../packageF/consumption/commodity/commodity?storeId=".concat(o)
        });
    },
    onLoad: function(t) {
        this._getData();
    },
    onStoreChange: function(t) {
        console.log(t), this.setData({
            collectIndex: t.detail.name
        });
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {}
});